package Linux五种IO模型.reactor2;

import java.util.concurrent.*;

/**
 * @author coderFu
 * @create 2022/3/8
 *
 * 自定义线程池
 */
public class ReactorThreadPool {

    private static ThreadPoolExecutor  threadPoolExecutor;

    public  static ThreadPoolExecutor getThreadPoolExecutor(){
        if (threadPoolExecutor == null){
            synchronized (ReactorThreadPool.class){
                if (threadPoolExecutor == null){
                    threadPoolExecutor = new ThreadPoolExecutor(
                            10,
                            20,
                            20,
                            TimeUnit.SECONDS,
                            new LinkedBlockingDeque<>(20),
                            new NamedThreadFactory("Reactor"));
                }
            }
        }
        return threadPoolExecutor;
    }
}
